using APP.HELPER.Utils.Security;
using System;
using System.Data;
using System.Runtime.CompilerServices;
using System.Threading;

namespace APP.HELPER.Utils.Net
{
    //public class SendMail
    //{
    //    public bool Send2(string from, string yourname, string userID, string password, string subject, string content, string App)
    //    {
    //        bool result;
    //        try
    //        {
    //            Email email = new Email(from, yourname);
    //            email.AddToAddress(userID, App + " Contact");
    //            email.AssignGmailSsl(userID, password);
    //            email.Content(subject, content);
    //            email.Send();
    //            result = true;
    //        }
    //        catch (Exception)
    //        {
    //            result = false;
    //        }
    //        return result;
    //    }
    //}

    public class SendMail
    {
        [CompilerGenerated]
        private sealed class Class57
        {
            public Email email_0;
            public void method_0()
            {
                this.email_0.Send();
            }
        }
        private string string_0 = "support@perfect.com.vn";
        private string string_1 = MyEncryption.Decrypt("Gvf7D8v0ux292tBJm2Ftjg==", "", true);
        public bool Send(string toAddress, string toPerson, string subject, string content, string App)
        {
            this.method_0();
            bool result;
            try
            {
                SendMail.Class57 @class = new SendMail.Class57();
                @class.email_0 = new Email(toAddress, toPerson);
                @class.email_0.AddToAddress(this.string_0, App + " Contact");
                @class.email_0.AssignSslSmtp("smtp.gmail.com", 587, this.string_0, this.string_1);
                @class.email_0.Content(subject, content);
                Thread thread = new Thread(new ThreadStart(@class.method_0));
                thread.Start();
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }
            return result;
        }
        private void method_0()
        {
            try
            {
                DataSet dataSet = new DataSet();
                dataSet.ReadXml("http://update.fessoft.com/support.xml");
                this.string_0 = dataSet.Tables[0].Rows[0]["Account"].ToString();
                this.string_1 = MyEncryption.Decrypt(dataSet.Tables[0].Rows[0]["Password"].ToString(), "", true);
            }
            catch
            {
            }
        }
    }
}
